package com.wu.controller;

import com.wu.pojo.res.Result;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;

import java.util.HashMap;

public class Commonts {

    public static Result getErrors(BindingResult result) {
        HashMap<Object, Object> map = new HashMap<>();
        if (result.hasErrors()) {
            FieldError error = result.getFieldErrors().get(0);
            return Result.fail(error.getDefaultMessage());
        }
        return null;
    }
}
